<template>
	<view class="page">

		<view @click="show = true" class="u-flex u-row-between u-padding-20 u-margin-bottom-20 "
			style="border: 3rpx solid #3464D6; width: 700rpx;margin: auto;border-radius:10rpx;margin-top: 20rpx;">
			<view>
				{{date}}
			</view>
			<view>
				<u-icon name="calendar-fill" color="#3464D6" size="50"></u-icon>
			</view>
		</view>
		
		<u-gap bg-color="#f1f1f1" height="10"></u-gap>
		
		<u-tabs :list="nav" :is-scroll="false" :current="current" @change="changenav" ></u-tabs>
	


		<List :list="list" @end="end"></List>
		<u-loadmore :status="initial.status" />
		<u-calendar v-model="show" mode="range" @change="change"></u-calendar>

	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';
	import List from './components/carList.vue';
	export default {
		components: {
			List
		},
		mixins: [loader],
		data() {

			return {
				tabbar: [],
				nav: [{
					name: '充值订单'
				}, {
					name: '洗车订单'
				}],
				current: 0,
				list: [],
				initial: {
					geturl: "/api/alliance/orderList",
					parm: {
						store_id: '',
						date: "",
						status: 0,
						order_type:2
					},
					isPage: true
				},
				show: false,

				date: '时间筛选'



			}
		},
		async onLoad(options) {
			if (options.id) {
				this.initial.parm.store_id = options.id
			}
			this.getGoods()
		},
		methods: {
			end(item){
			  
			  this.$u.post('/api/alliance/finish', {
			      order_id:item.id
			  }).then(res => {	
			       	this.$refs.uToast.show({
			       		title: '订单结束成功',
			       		type: 'success',
			  			callback:()=>{
			  				this.initial.page=1;
							this.getGoods()
			  			}
			       	})
			  }).catch(err => {
			     
			  })
			},
			change(e) {
				var {
					endDate,
					startDate
				} = e;
				const date = startDate + ' '+ '-' +  ' '+ endDate
				this.initial.parm.date = date;
				this.date=date;
				this.initial.page = 1;
				this.getGoods()
			},
			changenav(e){
				this.current=e;
				this.initial.page = 1;
				if(e==0){
					this.initial.parm.order_type = 2;
				}else{
					this.initial.parm.order_type = 1;
				}
				
				this.getGoods()
			}

		}
	}
</script>


<style>
	.list {
		background: #fff;
		width: 700rpx;
		margin: 20rpx auto;
		padding: 20rpx;
	}
</style>
